package com.samoiloff.util {

	/**
	 * @author Damirr
	 */
	public class TimeUtil {
		
		public static function getMins(timeInSecs : int) : String {
			var min : int = Math.floor(timeInSecs / 60);
			min = min%60;
			return formatNum(min);
		}

		public static function getSecs(timeInSecs : int) : String {
			var sec : int = timeInSecs%60;
			return formatNum(sec);
		}
		
		public static function getHours(timeInSecs:int):String {
			var hours:int  = Math.floor(timeInSecs/3600);
			return formatNum(hours);
		}
		
		public static function timeToString(timeInSecs:int):String {
			//return getHours(timeInSecs)+":"+getMins(timeInSecs)+":"+getSecs(timeInSecs);
			var date:Date = new Date(timeInSecs*1000);
			//date.setSeconds(timeInSecs/1000);
			return formatNum(date.getDate()) +"." + formatNum(date.getMonth()+1) +"." + date.getFullYear();
		}
		
		private static function formatNum(n : int) : String {
			if (n < 10) return "0" + n;
			return n.toString();
		}
		
	}
}
